package intjavatorpedo.db;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Coord", propOrder = {
    "row",
    "col",
    "succesfullyBombed"
})
public class Coord {
	@XmlElement(name = "row", nillable = false)
	private int row;
	@XmlElement(name = "col", nillable = false)
	private int col;
	@XmlElement(name = "succesfullyBombed", nillable = true)
	private boolean succesfullyBombed;
	
	public Coord() {
		
	}
	
	public Coord(int row, int col)
	{
		this.setRow(row);
		this.setCol(col);
		this.setSuccesfullyBombed(false);
	}

	public int getRow() {
		return row;
	}

	private void setRow(int row) {
		this.row = row;
	}

	public int getCol() {
		return col;
	}

	private void setCol(int col) {
		this.col = col;
	}

	public boolean isSuccesfullyBombed() {
		return succesfullyBombed;
	}

	public void setSuccesfullyBombed(boolean success) {
		this.succesfullyBombed = success;
	}
	
	public boolean equals(Coord c) {
		return this.row == c.row && this.col == c.col;
	}
	
	public boolean isInside(int rows, int cols) {
		return this.row >= 0 && this.row < rows && this.col >= 0 && this.col < cols;
	}
}
